import React, { Component } from 'react'
import ThemeContext from './context/theme-context'
import UserContext from './context/user-context'

export class HomeInfo extends Component {
  render() {
    console.log(this.context)
    // 第四部: 从context中获取具体数据
    const { color, size } = this.context

    return (
      <div>
        HomeInfo: {color}, {size}
        <UserContext.Consumer>
          {(value) => {
            return <h2>{value.nickname}</h2>
          }}
        </UserContext.Consumer>
      </div>
    )
  }
}

// 第三部.设置具体是那个context传递过来的数据
HomeInfo.contextType = ThemeContext

export default HomeInfo
